@extends('admin.layout')
@section('title','订单列表')
@section('body')
<div class="container1">
    <div id="search" style="height:63px;">
        <blockquote class="layui-elem-quote" style="font-size: 14px">
            <form action="{{url('http://egui.gebixianxiang.com:8081/BGoods/Data/bySn')}}" method="post" class="layui-form">
                <div class="layui-form-item">
                    <div  class="layui-inline">
                        <label class="layui-form-label">搜索</label>
                        <div class="layui-input-inline">
                            <input type="tel" id="Sn" name="Sn"  lay-verify="required" placeholder="请输入订单号" autocomplete="off" class="layui-input ">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <input  type="button"  onclick="sear()" class="layui-btn layui-btn-small" value="搜索">
                    </div>
                    <div class="layui-inline">
                        商品销售额@{{count.total}}元,成交订单@{{count.num}}笔.
                    </div>
                </div>

            </form>
        </blockquote>
    </div>
    <div id="search" style="height:63px;">
        <blockquote class="layui-elem-quote" style="font-size: 14px" >
            <form action="" method="post" class="layui-form" @if($user->type==2) style="display: none" @endif>
                <div class="layui-form-item">
                    <div  class="layui-inline" >
                        <label class="layui-form-label">经销商</label>
                        <div class="layui-input-inline" >
                            <select name="admin_id" lay-filter="admin" lay-verify="" lay-search>
                                <option value="0">选择</option>
                                @foreach($admin as $value)
                                <option value="{{$value->admin_id}}">{{$value->username}}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div  class="layui-inline" @if($user->type==2) style="display: none" @endif>
                        <label class="layui-form-label">按店铺</label>
                        <div class="layui-input-inline">
                            <select name="shop_id" lay-filter="shop" lay-verify="" lay-search>
                                <option value="0">选择</option>
                                @foreach($shop as $value)
                                    <option value="{{$value->id}}">{{$value->grogsgopname}}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>

                    <div  class="layui-inline">
                        <label class="layui-form-label">按分类</label>
                        <div class="layui-input-inline">
                            <select name="class_id" lay-filter="class" lay-verify="" lay-search>
                                <option value="0">选择</option>
                                @foreach($class as $value)
                                    <option value="{{$value->id}}">{{$value->name}}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>

                </div>
                <input type="reset" id="reset" value="" style="display:none;">
            </form>
        </blockquote>
    </div>
    <table class="layui-table " >
        <colgroup>

        </colgroup>
        <thead>
        <tr>
            <th>分销商</th>
            <th>店铺名</th>
            <th>店铺订单号</th>
            <th>支付平台订单号</th>
            <th>支付时间</th>
            <th>支付金额</th>
        </tr>
        </thead>
        <tbody>
            <tr v-for="value in lists">
                <td>@{{value.username}}</td>
                <td>@{{value.grogsgopname}}</td>
                <td>@{{value.border_sn}}</td>
                <td>@{{value.pay_Sn}}</td>
                <td>@{{value.pay_time}}</td>
                <td>@{{value.bgoods_amount}}</td>
            </tr>
        </tbody>
    </table>
    <div id="page"></div>
    <div id="page1"></div>
    <div id="page2"></div>
    <div id="page3"></div>
    <div id="dialog" style="display: none">
       <table class="table table-bordered table-responsive">
           <tr>
               <td>分销商</td>
               <td>@{{orderdetail.adminname}}</td>
               <td>店铺</td>
               <td>@{{orderdetail.shopname}}</td>
           </tr>
           <tr>
               <td>柜机</td>
               <td>@{{orderdetail.chesname}}</td>
               <td>商品</td>
               <td>@{{orderdetail.goodsname}}</td>
           </tr>
           <tr>
               <td>价格</td><td>@{{orderdetail.price}}</td>
               <td>时间</td><td>@{{orderdetail.time}}</td>
           </tr>
           <tr>
               <td  colspan="2">图片</td>
               <td colspan="2"><img :src="orderdetail.image" style="width: 200px;" alt=""></td>
           </tr>
       </table>
    </div>
</div>
@endsection
@section('js')
    <script src="{{asset('js/vue.min.js')}}"></script>
    <script>
        @if(Session::has('message'))
             layer.msg("{{Session::get("message")}}");
        {{Session::forget('message')}}
        @endif

        var vm=new Vue({
            el:".container1",
            data:{
                lists:"",
                count:"",
                orderdetail:""

            },
            mounted:function () {
                layui.use(['laypage', 'layer','form'], function() {
                    var laypage = layui.laypage,layer = layui.layer,form = layui.form();
                    $("#page").show();
                    $("#page1").hide();
                    $("#page2").hide();
                    $("#page3").hide();
                    laypage({
                        cont: 'page'
                        ,pages:'{{$pages}}'
                        ,skin: '#1E9FFF'
                        ,skip:true
                        ,jump:function (obj,first) {
                            @if($user->type==2)
                                if(first){
                                    $.get({
                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data/bydistributor',
                                        data:{'pages':1,'adminid':"{{$user->admin_id}}"},
                                        success:function (res) {
                                            vm.count=res.Data;
                                            vm.lists=res.Order;
                                            obj.pages=Math.ceil((res.Data.num)/15);
                                        }
                                    })
                                }else{
                                    $.get({
                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data/bydistributor',
                                        data:{'pages':obj.curr,'adminid':"{{$user->admin_id}}"},
                                        success:function (res) {
                                            vm.count=res.Data;
                                            vm.lists=res.Order;
                                            obj.pages=Math.ceil((res.Data.num)/15);
                                        }
                                    })
                                }
                                @else
                                if(first){
                                    $.get({
                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data//byall',
                                        data:{'pages':1},
                                        success:function (res) {
                                            vm.count=res.Data;
                                            vm.lists=res.Order;
                                            obj.pages=Math.ceil((res.Data.num)/15);
                                        }
                                    })
                                }else{
                                    $.get({
                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data//byall',
                                        data:{'pages':obj.curr},
                                        success:function (res) {
                                            vm.count=res.Data;
                                            vm.lists=res.Order;
                                            obj.pages=Math.ceil((res.Data.num)/15);
                                        }
                                    })
                                }


                            @endif

                        }
                    });
                    form.on('select(admin)', function(data){
                        $("#reset").click();
                        if(data.value==0){

                            $.get({
                                url:'http://egui.gebixianxiang.com:8081/BGoods/Data//byall',
                                data:{'pages':1},
                                success:function (res) {
                                    vm.count=res.Data;
                                    vm.lists=res.Order;
                                    obj.pages=Math.ceil((res.Data.num)/15);
                                }
                            })
                        }else{
                            $.get({
                                url:'{{url('http://egui.gebixianxiang.com:8081/BGoods/Data/bydistributor')}}',
                                data:{'pages':1,'adminid':data.value},
                                success:function (res) {
                                    vm.count=res.Data;
                                    vm.lists=res.Order;
                                    $("#page").hide();
                                    $("#page1").show();
                                    $("#page2").hide();
                                    $("#page3").hide();
                                    laypage({
                                        cont: 'page1'
                                        ,pages:2
                                        ,skin: '#1E9FFF'
                                        ,skip:true
                                        ,jump:function (obj,first) {
                                            if(first){
                                                $.get({
                                                    url:'http://egui.gebixianxiang.com:8081/BGoods/Data/bydistributor',
                                                    data:{'pages':1,'adminid':data.value},
                                                    success:function (res) {
                                                        vm.count=res.Data;
                                                        vm.lists=res.Order;
                                                        obj.pages=Math.ceil((res.Data.num)/15);
                                                    }
                                                })
                                            }else{
                                                $.get({
                                                    url:'http://egui.gebixianxiang.com:8081/BGoods/Data/bydistributor',
                                                    data:{'pages':obj.curr,'adminid':data.value},
                                                    success:function (res) {
                                                        vm.count=res.Data;
                                                        vm.lists=res.Order;
                                                        obj.pages=Math.ceil((res.Data.num)/15);
                                                    }
                                                })
                                            }
                                        }
                                    });
                                }
                            })

                        }
                    });

                    form.on('select(shop)', function(data){
                        $("#reset").click();
                        if(data.value==0){
                            $.get({
                                url:'http://egui.gebixianxiang.com:8081/BGoods/Data//byall',
                                data:{'pages':1},
                                success:function (res) {
                                    vm.count=res.Data;
                                    vm.lists=res.Order;
                                    obj.pages=Math.ceil((res.Data.num)/15);
                                }
                            })
                        }else{
                            $.get({
                                url:'{{url('http://egui.gebixianxiang.com:8081/BGoods/Data/byshop')}}',
                                data:{'pages':1,'shopid':data.value},
                                success:function (res) {
                                    vm.count=res.Data;
                                    vm.lists=res.Order;
                                    $("#page").hide();
                                    $("#page1").hide();
                                    $("#page2").show();
                                    $("#page3").hide();
                                    laypage({
                                        cont: 'page2'
                                        ,pages:2
                                        ,skin: '#1E9FFF'
                                        ,skip:true
                                        ,jump:function (obj,first) {
                                            if(first){
                                                $.get({
                                                    url:'http://egui.gebixianxiang.com:8081/BGoods/Data/byshop',
                                                    data:{'pages':1,'shopid':data.value},
                                                    success:function (res) {
                                                        vm.count=res.Data;
                                                        vm.lists=res.Order;
                                                        obj.pages=Math.ceil((res.Data.num)/15);
                                                    }
                                                })
                                            }else{
                                                $.get({
                                                    url:'http://egui.gebixianxiang.com:8081/BGoods/Data/byshop',
                                                    data:{'pages':obj.curr,'shopid':data.value},
                                                    success:function (res) {
                                                        vm.count=res.Data;
                                                        vm.lists=res.Order;
                                                        obj.pages=Math.ceil((res.Data.num)/15);
                                                    }
                                                })
                                            }
                                        }
                                    });
                                }
                            })
                        }
                    });

                    form.on('select(class)', function(data){
                        $("#reset").click();
                        if(data.value==0){
                            $.get({
                                url:'http://egui.gebixianxiang.com:8081/BGoods/Data//byall',
                                data:{'pages':1},
                                success:function (res) {
                                    vm.count=res.Data;
                                    vm.lists=res.Order;
                                    obj.pages=(res.Data.num)/15;
                                }
                            })
                        }else{
                            $.get({
                                url:'{{url('http://egui.gebixianxiang.com:8081/BGoods/Data/byclass')}}',
                                data:{'pages':1,'classid':data.value},
                                success:function (res) {
                                    vm.count=res.Data;
                                    vm.lists=res.Order;
                                    $("#page").hide();
                                    $("#page1").hide();
                                    $("#page2").show();
                                    $("#page3").hide();
                                    laypage({
                                        cont: 'page3'
                                        ,pages:2
                                        ,skin: '#1E9FFF'
                                        ,skip:true
                                        ,jump:function (obj,first) {
                                            if(first){
                                                $.get({
                                                    url:'http://egui.gebixianxiang.com:8081/BGoods/Data/byclass',
                                                    data:{'pages':1,'classid':data.value},
                                                    success:function (res) {
                                                        vm.count=res.Data;
                                                        vm.lists=res.Order;
                                                        obj.pages=(res.Data.num)/15;
                                                    }
                                                })
                                            }else{
                                                $.get({
                                                    url:'http://egui.gebixianxiang.com:8081/BGoods/Data/byclass',
                                                    data:{'pages':obj.curr,'classid':data.value},
                                                    success:function (res) {
                                                        vm.count=res.Data;
                                                        vm.lists=res.Order;
                                                    }
                                                })
                                            }
                                        }
                                    });
                                }
                            })
                        }
                    });



                });
            }

        });


        function sear() {
            var Sn=$("#Sn").val();
            layui.use('form');
            $.ajax({
                url:"http://egui.gebixianxiang.com:8081/BGoods/Data/bySn",
                type:'get',
                data:{"Sn":Sn},
                success:function (res) {
                   vm.orderdetail=res.SnOrder;
                }
            });
            layer.open({
                title:"订单详情",
                content:$("#dialog"),
                area: ['1200px', '600px'],
                type:1
            })
        }
    </script>

@endsection
